package pers.archives.common.ov.common;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/* 统一返回值类型
 *@program:archives-parent
 *@author: 赵浩浩
 *@Time: 2020/8/12  22:06
 */
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
@Data
public class CommonResponse<T> implements Serializable {

    /**
     * 返回值
     */
    private Integer code;

    /**
     * 返回值说明
     */
    private String message;

    /**
     * 返回值
     */
    private T data;

    /**
     *
     * @param c 状态码
     * @param t 需要返回的参数
     */
    public CommonResponse(ResponseCode c, T t) {
        this.code = c.getCode();
        this.message = c.getMessage();
        this.data = t;
    }

    public String toString() {
        return JSON.toJSONString(this);
    }
}
